package com.qfedu.yanglao20admin.health.common;

public enum RoleEnum {

    // 该写法表示要调用对应的构造方法
    ADMIN(1, "启用"),
    NORMAL(0, "禁用");

    // 枚举中可以定义成员变量
    private int id;
    private String state;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    RoleEnum(int id, String state) {
        this.id = id;
        this.state = state;
    }

    // 根据指定的数据，获取枚举类型的对象
    public static RoleEnum getRoleById(int id) {
        // 获取所有的枚举值
        RoleEnum[] values = RoleEnum.values();
        for (RoleEnum role : values) {
            if (role.getId() == id) {
                return role;
            }
        }
        return null;
    }
}
